package user_login_program;

import java.util.Scanner;

public class Login {
    public static final String NAME = "黑予督";
    public static final String PASSWORD = "250250";
    public static void login() throws UserNameException, PassWordException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Input your name");
        String name = scanner.next();
        System.out.println("Enter the password");
        String password = scanner.next();
        if (!NAME.equals(name)){
            throw new UserNameException("The user's name is incorrect");
        }
        if (!PASSWORD.equals(password)){
            throw new PassWordException("The user's password is incorrect");
        }
    }

    public static void main(String[] args)throws UserNameException, PassWordException {
        try {
            login();
            System.out.println("Login successfully");
        }catch (UserNameException exception){
            System.out.println("The user's name is incorrect");
        }catch (PassWordException exception){
            System.out.println("The user's password is incorrect");
        }
        catch (Exception exception){
            System.out.println("exception");
        }
    }


}
class UserNameException extends RuntimeException{
    public UserNameException(String message){
        super(message);
    }
}
class PassWordException extends Exception{
    public PassWordException(String message){
        super(message);
    }
}
